home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Utilities / modal-dialog-sample ƒ / Buttons.c next >
Encoding:
C/C++ Source or Header  |  1991-10-26  |  925 b   |  46 lines  |  [TEXT/KAHL]

  1. /*
  2. **    Project    dialog example
  3. **    Module    Buttons.c
  4. **    Author    Bernie Wieser ©1991
  5. **    Date    10/26/91
  6. **
  7. **    Purpose
  8. **        Routines to handle dialog buttons.
  9. **
  10. */
  11. #include "Buttons.h"
  12.  
  13. short PressButton(        /* fake a button press */
  14.     DialogPtr    dp,        /* button's dlog */
  15.     short        item,    /* the button id */
  16.     long        delay    /* delay down */
  17.     )                    /* return failure if button inactive */
  18. {
  19.     short    type;
  20.     Handle    object;
  21.     Rect    rect;
  22.     
  23.      GetDItem(dp, item, &type, &object, &rect);
  24.      if(type&itemDisable) return(-1);
  25.     HiliteControl(object, TRUE);
  26.     Delay(delay, &delay);
  27.     HiliteControl(object, FALSE);
  28.     return(0);
  29. }
  30.  
  31. short DefaultButton(    /* highlight the default button */
  32.     DialogPtr    dp,        /* the button's dialog */
  33.     short        item    /* the button's id, usually 1 */
  34.     )
  35. {
  36.     Rect    r;
  37.     Handle    h;
  38.     short    type;
  39.     
  40.     GetDItem(dp, item, &type, &h, &r);
  41.     if(type&itemDisable) return(-1);
  42.     PenSize(3,3);
  43.     InsetRect(&r,-4,-4);
  44.     FrameRoundRect(&r,16,16);
  45.     return(0);
  46. }